﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using log4net;

namespace OA.Log
{

    public class Logger
    {
        private static readonly ILog _ilog = null;
        private static readonly string logName = "MyLogging";

        static Logger()
        {           
            _ilog = LogManager.GetLogger(logName);
        }

        public static void LogDebug(string message)
        {            
            if (_ilog.IsDebugEnabled)
            {
                _ilog.Debug(message);
            }
        }

        public static void LogDebug(Exception e)
        {
            if (_ilog.IsDebugEnabled)
            {
                _ilog.Debug(e.Message, e);
            }
        }       

        public static void LogInfo(string message)
        {
            if (_ilog.IsInfoEnabled)
            {
                _ilog.Info(message);
            }
        }

        public static void LogInfo(Exception e)
        {
            if (_ilog.IsInfoEnabled)
            {
                _ilog.Info(e.Message, e);
            }
        }


        public static void LogError(string message)
        {
            if (_ilog.IsErrorEnabled)
            {
                _ilog.Error(message);
            }
        }

        public static void LogError(Exception e)
        {
            if (_ilog.IsErrorEnabled)
            {
                _ilog.Error(e.Message, e);
            }
        }

        public static void LogFatal(string message)
        {
            if (_ilog.IsFatalEnabled)
            {
                _ilog.Fatal(message);
            }
        }

        public static void LogFatal(Exception e)
        {
            if (_ilog.IsFatalEnabled)
            {
                _ilog.Fatal(e.Message, e);
            }
        }

        public static void LogWarn(string message)
        {
            if (_ilog.IsWarnEnabled)
            {
                _ilog.Warn(message);
            }
        }

        public static void LogWarn(Exception e)
        {
            if (_ilog.IsWarnEnabled)
            {
                _ilog.Warn(e.Message, e);
            }
        }
    }  

}
